/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __ATC_PRESENTER_HDR__
#define __ATC_PRESENTER_HDR__

#include <q3widgetstack.h>
//Added by qt3to4:
#include <QKeyEvent>
#include "experiment.h"
#include "global.h"
#include <map>

#define GLOBALVARIABLES std::map<std::string,Global*> 

namespace pact{

	const std::string CHOICE_QUESTION_SELECTION = "ChoiceQuestionSelection";
	const std::string FEEDBACK_VALUE = "FeedbackValue";
	const std::string SR_GOAL_CHOICE = "SRGoalChoice";
	const std::string SR_GOAL = "SRGoal";
	const std::string NORM_GOAL_CHOICE = "NormGoalChoice";
	const std::string NORM_GOAL = "NormGoal";

	/*!
	 */
	class Presenter : public Q3WidgetStack {
		Q_OBJECT
	public:
		static Presenter* instance();
		void destroy();
	private:
		Presenter(QWidget * = 0, const char * = 0);
		virtual ~Presenter();
	public:
		void setExperiment(pact::Experiment *);
	public:
		GLOBALVARIABLES& globals() { return _globals; }
		long GetTrialTaskScore(const std::string& a_trialId) const;
		void SetGlobalIdx(const std::string& a_idx) { m_globalIdx = a_idx; }
		std::string GlobalIdx() const { return m_globalIdx; }
		std::string CurrentTrialTask() const { return m_trialTasks[m_trialTasks.size() - 1]; }
		unsigned int CurrentTrialTaskNumber() const { return m_trialTasks.size(); }

	public slots:
		void presentTask();
		void start();
		void LogTrialTaskScore(long a_score);
	protected:
		void keyPressEvent(QKeyEvent *);
	private:
		static Presenter *_instance;
	private:
		const pact::Experiment*		_experiment;
		PresentationTasksCIt		_task;
		PresentationTasksCIt		_end_task;
		GLOBALVARIABLES				_globals;
		std::map<std::string, long>	m_trialScores;
		std::vector<std::string>	m_trialTasks;
		std::string					m_globalIdx;
	};
	
	typedef GLOBALVARIABLES GlobalVariables;
}

#undef GLOBALVARIABLES


#endif
